//
//  LGRootTool.m
//  微博
//
//  Created by MS on 15-12-6.
//  Copyright (c) 2015年 MS. All rights reserved.
//

#import "LGRootTool.h"
#import "LGTabbarController.h"
#import "LGNewFeatureController.h"

#define LGVersion @"LGVersion"
@implementation LGRootTool

+(void) chooseRootViewController:(UIWindow *)window
{
    //判断当前是否有新版本，如果有进入新特性
    
    //1.获取当前版本号
    NSString * currenVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
    
    //2.获取上次版本号
    NSString * lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:LGVersion];
    
    if ([currenVersion isEqualToString:lastVersion]) {//无新版本
        
        //创建tabbar
        LGTabbarController * tabbarController =[[LGTabbarController alloc]init];
        window.rootViewController = tabbarController;
    }
    
    else{//有新版本
        
        LGNewFeatureController * newFearture = [[LGNewFeatureController alloc] init];
        
        window.rootViewController = newFearture;
        
        //3.保存当前版本
        
        [[NSUserDefaults standardUserDefaults] setObject:currenVersion forKey:LGVersion];
    }
    
    
    
}

@end
